package com.hngd.controller;

import com.hngd.model.Category;
import com.hngd.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/category")
//@CrossOrigin  //解决跨域访问
public class CategoryController {
    //注入持久层数据
    @Autowired
    private CategoryService service;

    @GetMapping
    public List<Category> findAll(){
        return service.findAll();
    }
}
